<?php
if(!defined('BZ_plugin')) {
	exit('Bingz:plugin:Access Denied');
}
$id=$_GET['id'];
$ama=$_GET['ama'];
$lid=$_GET['lid'];

if($ama =='xg'){
   $rowuser=$db->get_one('plugin_liaotian_class'," `id` ='$id'",'');
echo <<<end
<div class="admin">管理房间</div>
	<form action="$plugin_admindz&pod=index&ama=xgok&id={$id}" method="POST" >
    聊天房间名称:<br />
  	<input class="text" type="text" name="name" size="25" value="$rowuser[name]" maxlength="5" /><br/>
  	聊天房间公告<br/>
  	<input class="text" type="text" name="content" size="100" value="$rowuser[content]" maxlength="5" /><br/>
  	聊天房间图标(http://)<br/>
  	<input class="text" type="text" name="logo" size="100" value="$rowuser[logo]" maxlength="5" /><br/>
  	私密聊天密码(可空)<br/>
  	<input class="text" type="text" name="pass" size="25" value="$rowuser[pass]" maxlength="5" /><br/>
    <input class="submit" type="submit" name="adminpost" value="提交" />
</form>
end;
echo"<br/><a href=\"$plugin_admindz&pod=index&&ama=scts&id=$id&\">删除房间</a><br/>";
       $num_count=$db->num_rows('plugin_liaotian'," `lid` ='$id'",'id');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('plugin_liaotian',"`lid` ='$id' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
       while($row=mysql_fetch_array($sql_bbs)){
	           $hyname=' <a href="index.php?m=user&uid='.$row[uid].'">'.$user_class->user_name($row[uid]).'</a>';
	           if($row[uid] == '0'){
	           	  $hyname='系统';
             }
             $content=$ubb->content_ubb($row[content]);
	           echo"<div class=\"admin_a\">$hyname ：$content
	           <a href=\"$plugin_admindz&pod=index&ama=sclt&id=$row[lid]&lid=$row[id]\">删除</a></div>";
       }
if(!$num_count){
echo <<<end
<div class="admin_a">没有聊天数据！</div>
end;
}
echo $page=page_link($list_num,$num_count);


}else if($ama=='xgok'){
    if(!$_POST[adminpost]){
	     echo"提交出错<br/>";
	  }else{
	  	$db->update('plugin_liaotian_class'," `name` = '$_POST[name]', `content` = '$_POST[content]',`logo` = '$_POST[logo]',`pass` = '$_POST[pass]' "," `id` ='$id'");
      echo"提交成功<br/>";
    }
    echo "正在自动返回.......<br/><a href=\"$plugin_admindz&pod=index&ama=xg&id=$id\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=$plugin_admindz&pod=index&ama=xg&id=$id'>";
}else if($ama=='scts'){
	 echo'<div class="admin">删除房间</div>注意：删除后不可恢复<br/>';
	 echo"<a href=\"$plugin_admindz&pod=index&&ama=sc&id=$id&\">确定删除</a><br/>";
}else if($ama=='sc'){
   $db->delete('plugin_liaotian_class',"`id` = '$id'");
	 echo"删除成功<br/>";
   echo "正在自动返回.......<br/><a href=\"$plugin_admindz&pod=index\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=$plugin_admindz&pod=index'>";
}else if($ama=='sclt'){
   $db->delete('plugin_liaotian',"`id` = '$lid'");
	 echo"删除成功<br/>";
   echo "正在自动返回.......<br/><a href=\"$plugin_admindz&pod=index&ama=xg&id=$id\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=$plugin_admindz&pod=index&ama=xg&id=$id'>";
}else{
       $num_count=$db->num_rows('plugin_liaotian_class',"1 ",'id');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('plugin_liaotian_class',"1 ORDER BY `id` LIMIT ".$num_start." , ".$list_num." ",'');
       while($row=mysql_fetch_array($sql_bbs)){
	           $hyname=' <a href="index.php?m=user&uid='.$row[uid].'">'.$user_class->user_name($row[uid]).'</a>';
	           if($row[uid] == '0'){
	           	  $hyname='系统';
             }
	           echo"<div class=\"admin_a\">房间：<b>$row[name]</b>  
	           <a href=\"$plugin_admindz&pod=index&ama=xg&id=$row[id]\">管理房间</a><br/>
	           所属会员：$hyname </div>";
       }
       echo $page=page_link($list_num,$num_count);
}
?>
